import datetime

from rest_framework.response import Response
from rest_framework.views import APIView


from mycelery.celery_task.task_one import send_message_one
from mycelery.celery_task.task_two import send_email_one

# Create your views here.
class TestAPIView(APIView):
    def get(self,request):
        print('123')
        return Response({'hello':'world'})

class TestAPIView2(APIView):
    def get(self,request):
        res = '欲买桂花同载酒，终不似少年游！！！'
        abs = send_message_one.delay(res)
        print(abs)
        return Response("发送成功")

class TestAPIView3(APIView):
    def get(self,request):
        eta = datetime.datetime.now() + datetime.timedelta(seconds=5)
        res = 'email欲买桂花同载酒，终不似少年游！！！'
        abs = send_email_one.apply_async(args=[res,],eta=eta)
        print(abs)
        return Response("email发送成功")

